﻿@************************************************************************************//
// Autor:  						                				     				*//
//***********************************************************************************//
// SearchIndex()	Acceso INVITADO	y ADMINISTRADOR									*//
// Vista que devuelve todos los ítems de Proveedores listados, paginados y con	 	*//
// opción de búsqueda.		 														*//
// _________________________________________________________________________________*@

@model PagedList.IPagedList<SIBI.Models.Proveedor>
@{
    ViewBag.Title = "Proveedor";
}

<h2>Proveedor</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

    @using (Html.BeginForm()){   
            <table width="100%">
                    <tr>
                        <td>   
                            Nombre:<br /> @Html.TextBox("SearchNPer", ViewBag.CurrentNper as string) &nbsp;
                        </td>
                        <td> 
                            Descripción:<br /> @Html.TextBox("SearchEmp", ViewBag.CurrentEmp as string) &nbsp;
                        </td>
                    </tr>
            </table>
         <input type="submit" value="Filtrar" />
    }

<br />
<p>
    @Html.ActionLink("Crear Nuevo", "Create")
</p>
<table width="100%">
    <tr>
        <th>
            Nombre
        </th>
        <th>
            Contacto
        </th>
        <th>
            Ubicación
        </th>
        <th>
            Descripción
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.cnom)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.cres)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.cubi)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.cdes)
        </td>
        <td width="25%">
            @Html.ActionLink("Editar", "Edit", new { id=item.ProveedorId }) |
            @Html.ActionLink("Detalles", "Details", new { id=item.ProveedorId }) |
            @Html.ActionLink("Borrar", "Delete", new { id=item.ProveedorId })
        </td>
    </tr>
}

</table>
<br />

<div>
    Pag @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    de @Model.PageCount
    &nbsp;
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<= ", "SearchIndex", new { page = 1, currentNPer = ViewBag.CurrentNPer, currentEmp = ViewBag.CurrentEmp})
        @Html.Raw("&nbsp;");
        @Html.ActionLink("<=", "SearchIndex", new { page = Model.PageNumber - 1, currentNPer = ViewBag.CurrentNPer, currentEmp = ViewBag.CurrentEmp})
    }
    else
    {
        @:<<=
        @Html.Raw("&nbsp;");
        @:<=
    }
    &nbsp;
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("=>", "SearchIndex", new { page = Model.PageNumber + 1, currentNPer = ViewBag.CurrentNPer, currentEmp = ViewBag.CurrentEmp})
        @Html.Raw("&nbsp;");
        @Html.ActionLink(" =>>", "SearchIndex", new { page = Model.PageCount, currentNPer = ViewBag.CurrentNPer, currentEmp = ViewBag.CurrentEmp})
    }
    else
    {
        @:=>
        @Html.Raw("&nbsp;")
        @:=>>
    }
</div>